﻿import QtQuick 2.15
import QtQuick.Controls 2.12
import QtGraphicalEffects 1.15


Rectangle {
    property string imgSrc: "qrc:/images/maoguang"

    property int borderRadius: 5
    property real isRotatingAngel: 0.0
    property bool isRotating: false
    radius:borderRadius

    gradient:Gradient{
        GradientStop{
            position: 0.0
            color:"#101010"
        }
        GradientStop{
            position: 0.5
            color:"#a0a0a0"
        }
        GradientStop{
            position: 1.0
            color:"#505050"
        }
    }

    Image{
        id:image
        anchors.centerIn: parent
        source: imgSrc
        smooth: true
        visible: false
        width:parent.width *0.9
        height: parent.height*0.9
        fillMode: Image.PreserveAspectCrop
    }
    Rectangle{
        id:mask
        color:"black"
        anchors.fill: parent
        radius: borderRadius
        visible: false
        smooth: true
        border.width: 20
        border.color: "#ffffff"
        antialiasing: true
    }

   OpacityMask{
       id:maskImage
       anchors.fill: image
       source: image
       maskSource: mask
       visible: true
       antialiasing: true
   }

   NumberAnimation{
       running: isRotating
       loops:Animation.Infinite
       target: maskImage
       from:isRotatingAngel
       to:360 + isRotatingAngel
       property: "rotation"
       duration: 100000
       onStopped: {
           isRotatingAngel = maskImage.rotation
       }
   }

}
